----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/figure_03_phi_pop.log
  log type:  text
 opened on:  31 Oct 2022, 02:41:20

. *-------------------------------------------------------------------------------
. 
. 
. 
. *-----------------------------------------------------------------
. clear all

. use "${data}/estimates_agg_naics_sales_s1_base_woparent.dta", clear

. 
. local grvar0 "gdp_pw_ppp" 

. local grvar1 "" 

. local var3 "A"

. local yy "2016"

. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was float, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)
(note: variable type was str5, now str9 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                                27  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(2,985 observations deleted)

. drop _merge

. 
. foreach var in D_A  {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. }

. 
. local LHS1 D_`var3'_phi

. local LHS2 ln_`grvar0'

. local RHS ln_pop

. 
. 
. reg `LHS1' `LHS2' `RHS'

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(2, 24)        =    200.53
       Model |  .645714201         2  .322857101   Prob > F        =    0.0000
    Residual |  .038640316        24  .001610013   R-squared       =    0.9435
-------------+----------------------------------   Adj R-squared   =    0.9388
       Total |  .684354518        26  .026321328   Root MSE        =    .04012

-------------------------------------------------------------------------------
      D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
ln_gdp_pw_ppp |   .1696791   .0305353     5.56   0.000     .1066575    .2327008
       ln_pop |    .103251   .0063709    16.21   0.000      .090102    .1163999
        _cons |   .0150362   .0140514     1.07   0.295    -.0139645    .0440368
-------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c1: display %-04.2fc round(b[1,1],0.0001)

. global se1: display %-04.2fc round(sqrt(V[1,1]),0.0001)

. 
. 
. reg `LHS1' `RHS', nocon

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 26)        =    470.38
       Model |  1.71648939         1  1.71648939   Prob > F        =    0.0000
    Residual |  .094877256        26  .003649125   R-squared       =    0.9476
-------------+----------------------------------   Adj R-squared   =    0.9456
       Total |  1.81136665        27  .067087654   Root MSE        =    .06041

------------------------------------------------------------------------------
     D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      ln_pop |   .1245806   .0057441    21.69   0.000     .1127734    .1363879
------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c_first: display %-03.2fc round(b[1,1],0.0001)

. global se_first: display %-03.2fc round(sqrt(V[1,1]),0.0001)

. predict lhs, res

. 
. reg `LHS2' `RHS', nocon 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 26)        =     31.54
       Model |  2.81238372         1  2.81238372   Prob > F        =    0.0000
    Residual |   2.3183727        26  .089168181   R-squared       =    0.5481
-------------+----------------------------------   Adj R-squared   =    0.5308
       Total |  5.13075642        27  .190028016   Root MSE        =    .29861

------------------------------------------------------------------------------
ln_gdp_pw_~p |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      ln_pop |   .1594657   .0283945     5.62   0.000     .1010999    .2178315
------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c_second: display %-03.2fc round(b[1,1],0.0001)

. global se_second: display %-03.2fc round(sqrt(V[1,1]),0.0001)

. predict rhs, res

. 
. reg lhs rhs 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     32.84
       Model |  .052369611         1  .052369611   Prob > F        =    0.0000
    Residual |  .039862852        25  .001594514   R-squared       =    0.5678
-------------+----------------------------------   Adj R-squared   =    0.5505
       Total |  .092232463        26  .003547402   Root MSE        =    .03993

------------------------------------------------------------------------------
         lhs |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         rhs |   .1587333   .0276976     5.73   0.000     .1016889    .2157776
       _cons |   .0050653   .0081162     0.62   0.538    -.0116503    .0217809
------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c1: display %-03.2fc round(b[1,1],0.01)

. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. display "$c1"
0.16

. 
. 
. *Figure 
. *--------------------------------------------------------------------
. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0305")'{sub:n}"

. local xtitle "{&Delta}y{sub:n}"

. 
. global opt1 msymbol(circle_hollow) mlabel(isocode) mlabcolor(red)  msize(small) mlabsize(small)

. global opt2 msymbol(square_hollow) mlabel(isocode) mlabcolor(blue) msize(small) mlabsize(small)

. two (scatter lhs rhs, sort $opt1  mcolor(red)) (lfit lhs rhs, lcolor(red)) (line lhs lhs, lcolor(none)) ,  ylabel(-0.4(0.2)0.2, format(%5.1f) labsize(medlarge)) xlabel(-1(0.2)0
> .4, format(%5.1f) labsize(medlarge)) ///
>         title("", size(small)) ytitle("`ytitle'", size(medlarge)) xtitle("`xtitle'", size(medlarge)) graphregion(fcolor(white) lcolor(white)) ///
>         legend(order(2 "`ytitle': $c1 ($se1)") rows(1) size(medlarge) bplace(se) ring(0) region(lwidth(none))) 

. 
. graph export "${rmain}/fig_03.pdf", replace
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/main/fig_03.pdf written in PDF format)

. 
. 
. 
. 
.         
. 
.         
.         
.         
.         
.         
. 
end of do-file

. *-------------------------------------------------------------------------------

. 
. global typeden=1

. 
. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. . 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. 
. global lf "LF"

. 
. 
. 
. *Log

. 
. *cap log close

. 
. *log using "${clogs}/figure_06_alt_transfer_costs.log",replace

. 
. *-------------------------------------------------------------------------------

. 
. 
. 
. 
. 
. 
. 
. *-----------------------------------------------------------------

. 
. clear all

. 
. use "${data}/estimates_agg_naics_sales_s1_base_woparent.dta", clear

. 
. 
. 
. local grvar0 "gdp_pw_ppp" 

. 
. local grvar1 ""

. 
. local rr ""

. 
. local var3 "A"

. 
. local yy "2016"

. 
. local yy_ref=`yy'

. 
. replace year=`yy_ref'
(0 real changes made)

. 
. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was float, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)
(note: variable type was str5, now str9 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                                27  (_merge==3)
    -----------------------------------------

. 
. drop if _merge==2
(2,985 observations deleted)

. 
. drop _merge

. br

. *-----------------------------------------------------------------

. 
. clear all

. 
. use "${data}/estimates_sec_naics_sales_s1_base_woparent.dta", clear

. *-----------------------------------------------------------------

. 
. clear all

. 
. use "${data}/estimates_sec_naics_sales_s1_base_woparent.dta", clear

. 
. 
. 
. keep if type=="manuf"
(315 observations deleted)

. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${output}/estimates_sec_`title'.dta", clear
file /estimates_sec_naics_sales_s1_base_woparent.dta not found
r(601);

. 
. by year isocode, sort: egen num=count( fe_location )
no variables defined
r(111);

. 
. table isocode year, c(mean  num)
no variables defined
r(111);

. 
. keep if num>=`nn'
num not found
r(111);

. 
. keep year isocode
no variables defined
r(111);

. 
. duplicates drop 
no observations
r(2000);

. 
. tempfile iso

. 
. save `iso', replace
no variables defined
r(111);

. 
. 
. 
. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/estimates_sec_`title'.dta", clear

. 
. by year isocode, sort: egen num=count( fe_location )

. 
. table isocode year, c(mean  num)

----------------
          | year
  isocode | 2016
----------+-----
       AT |   17
       BE |   19
       BG |   17
       CZ |   18
       DE |   19
       DK |   18
       EE |   17
       ES |   18
       FI |   18
       FR |   18
       GB |   18
       GR |   17
       HR |   17
       HU |   18
       IT |   18
       JP |   15
       KR |   17
       LT |   17
       LV |   17
       MX |   15
       NL |   18
       PL |   18
       PT |   18
       RO |   19
       SE |   19
       SI |   18
       SK |   18
----------------

. 
. keep if num>=`nn'
(0 observations deleted)

. 
. keep year isocode

. 
. duplicates drop 

Duplicates in terms of all variables

(450 observations deleted)

. 
. tempfile iso

. 
. save `iso', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000u.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000u.tmp saved

. clear all

. 
. use "${data}/estimates_sec_naics_sales_s1_base_woparent.dta", clear

. 
. drop if sector1==sector
(0 observations deleted)

. 
. keep if type=="manuf" | type=="serv"
(153 observations deleted)

. 
. tab num_aff

  Number of |
    foreign |
 affiliates |
       in a |
ctry-sector |
       pair |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          1        0.31        0.31
          2 |          4        1.23        1.54
          3 |          4        1.23        2.78
          4 |          2        0.62        3.40
          5 |          4        1.23        4.63
          6 |          3        0.93        5.56
          7 |          3        0.93        6.48
          8 |          3        0.93        7.41
          9 |          4        1.23        8.64
         10 |          8        2.47       11.11
         11 |          6        1.85       12.96
         12 |          4        1.23       14.20
         13 |          6        1.85       16.05
         14 |          4        1.23       17.28
         15 |          4        1.23       18.52
         16 |          4        1.23       19.75
         17 |          3        0.93       20.68
         18 |          3        0.93       21.60
         19 |          2        0.62       22.22
         20 |          5        1.54       23.77
         21 |          4        1.23       25.00
         22 |          3        0.93       25.93
         23 |          4        1.23       27.16
         24 |          3        0.93       28.09
         25 |          4        1.23       29.32
         26 |          3        0.93       30.25
         27 |          4        1.23       31.48
         28 |          7        2.16       33.64
         29 |          2        0.62       34.26
         30 |          4        1.23       35.49
         31 |          2        0.62       36.11
         32 |          2        0.62       36.73
         33 |          1        0.31       37.04
         34 |          1        0.31       37.35
         35 |          3        0.93       38.27
         36 |          3        0.93       39.20
         37 |          2        0.62       39.81
         38 |          5        1.54       41.36
         39 |          2        0.62       41.98
         41 |          3        0.93       42.90
         42 |          2        0.62       43.52
         43 |          3        0.93       44.44
         44 |          2        0.62       45.06
         45 |          5        1.54       46.60
         46 |          2        0.62       47.22
         47 |          3        0.93       48.15
         48 |          3        0.93       49.07
         49 |          1        0.31       49.38
         50 |          2        0.62       50.00
         51 |          2        0.62       50.62
         53 |          2        0.62       51.23
         54 |          1        0.31       51.54
         55 |          3        0.93       52.47
         56 |          1        0.31       52.78
         57 |          1        0.31       53.09
         58 |          2        0.62       53.70
         60 |          1        0.31       54.01
         63 |          1        0.31       54.32
         64 |          1        0.31       54.63
         65 |          2        0.62       55.25
         66 |          2        0.62       55.86
         67 |          1        0.31       56.17
         68 |          2        0.62       56.79
         69 |          1        0.31       57.10
         70 |          1        0.31       57.41
         72 |          1        0.31       57.72
         74 |          3        0.93       58.64
         75 |          1        0.31       58.95
         76 |          1        0.31       59.26
         77 |          3        0.93       60.19
         78 |          1        0.31       60.49
         79 |          1        0.31       60.80
         80 |          3        0.93       61.73
         81 |          2        0.62       62.35
         83 |          5        1.54       63.89
         84 |          2        0.62       64.51
         85 |          2        0.62       65.12
         87 |          3        0.93       66.05
         88 |          4        1.23       67.28
         89 |          2        0.62       67.90
         91 |          1        0.31       68.21
         94 |          1        0.31       68.52
         95 |          1        0.31       68.83
         96 |          1        0.31       69.14
         97 |          2        0.62       69.75
         98 |          1        0.31       70.06
        100 |          1        0.31       70.37
        101 |          1        0.31       70.68
        107 |          2        0.62       71.30
        108 |          1        0.31       71.60
        110 |          3        0.93       72.53
        112 |          1        0.31       72.84
        113 |          1        0.31       73.15
        120 |          1        0.31       73.46
        121 |          1        0.31       73.77
        123 |          1        0.31       74.07
        124 |          1        0.31       74.38
        126 |          1        0.31       74.69
        127 |          2        0.62       75.31
        128 |          1        0.31       75.62
        131 |          1        0.31       75.93
        136 |          1        0.31       76.23
        137 |          2        0.62       76.85
        144 |          1        0.31       77.16
        150 |          1        0.31       77.47
        151 |          2        0.62       78.09
        152 |          1        0.31       78.40
        155 |          1        0.31       78.70
        156 |          3        0.93       79.63
        157 |          2        0.62       80.25
        161 |          1        0.31       80.56
        162 |          1        0.31       80.86
        167 |          1        0.31       81.17
        171 |          2        0.62       81.79
        174 |          1        0.31       82.10
        175 |          2        0.62       82.72
        178 |          1        0.31       83.02
        179 |          1        0.31       83.33
        187 |          1        0.31       83.64
        192 |          1        0.31       83.95
        199 |          1        0.31       84.26
        224 |          1        0.31       84.57
        230 |          1        0.31       84.88
        231 |          1        0.31       85.19
        238 |          1        0.31       85.49
        251 |          1        0.31       85.80
        255 |          1        0.31       86.11
        260 |          1        0.31       86.42
        272 |          1        0.31       86.73
        274 |          1        0.31       87.04
        279 |          1        0.31       87.35
        285 |          1        0.31       87.65
        286 |          1        0.31       87.96
        287 |          1        0.31       88.27
        299 |          1        0.31       88.58
        306 |          1        0.31       88.89
        310 |          2        0.62       89.51
        312 |          1        0.31       89.81
        321 |          1        0.31       90.12
        331 |          1        0.31       90.43
        334 |          1        0.31       90.74
        348 |          1        0.31       91.05
        353 |          1        0.31       91.36
        386 |          1        0.31       91.67
        394 |          1        0.31       91.98
        406 |          1        0.31       92.28
        426 |          1        0.31       92.59
        442 |          1        0.31       92.90
        444 |          1        0.31       93.21
        549 |          1        0.31       93.52
        561 |          1        0.31       93.83
        585 |          1        0.31       94.14
        604 |          2        0.62       94.75
        678 |          1        0.31       95.06
        700 |          1        0.31       95.37
        737 |          1        0.31       95.68
        760 |          1        0.31       95.99
        822 |          1        0.31       96.30
        850 |          1        0.31       96.60
        873 |          1        0.31       96.91
        886 |          1        0.31       97.22
        975 |          1        0.31       97.53
       1104 |          1        0.31       97.84
       1139 |          1        0.31       98.15
       1193 |          1        0.31       98.46
       1247 |          1        0.31       98.77
       1349 |          1        0.31       99.07
       1634 |          1        0.31       99.38
       1640 |          1        0.31       99.69
       1801 |          1        0.31      100.00
------------+-----------------------------------
      Total |        324      100.00

. br if num_aff<=3

. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/estimates_sec_`title'.dta", clear

. 
. 
. 
. drop if sector1==sector
(0 observations deleted)

. 
. keep if type=="manuf" 
(315 observations deleted)

. 
. sum num_aff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |        162    67.87654    78.91766          1        406

. 
. replace DA=. if num_aff<3
(4 real changes made, 4 to missing)

. 
. replace DP=. if num_aff<3
(0 real changes made)

. 
. levelsof sector, local(seclist)
`"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"ElecMach (26-28)"' `"Food (10-12)"' `"TexWood (13-18)"' `"TranspOtherManuf (29-33)"'

. 
. 
. global typeden=1

. 
. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. . 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. 
. global lf "LF"

. 
. 
. 
. *Log

. 
. *cap log close

. 
. *log using "${clogs}/figure_A3_phi_vs_z_manufsectors.log",replace

. 
. *-------------------------------------------------------------------------------

. 
. 
. 
. 
. 
. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/estimates_sec_`title'.dta", clear

. 
. drop if sector1==sector
(0 observations deleted)

. 
. keep if type=="manuf" 
(315 observations deleted)

. 
. sum num_aff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |        162    67.87654    78.91766          1        406

. 
. replace DA=. if num_aff<3
(4 real changes made, 4 to missing)

. 
. replace DP=. if num_aff<3
(0 real changes made)

. 
. 
. 
. 
. 
. local grvar0 "LP_ppp_emp_pwt" 

. 
. local grvar1 ""

. 
. local var3 "A"

. 
. local yy "2016"

. 
. local yy_ref=`yy'

. 
. replace year=`yy_ref'
(0 real changes made)

. 
. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was int, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                               162  (_merge==3)
    -----------------------------------------

. 
. drop if _merge==2
(2,985 observations deleted)

. 
. drop _merge

. 
. 
. 
. foreach var in D_A  {
  2. 
. gen `var'_phi=(-1)*`var'*(0.2)
  3. 
. *---------------------------------------
. 
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. 
. }
D_A not found
r(111);

. 
. 
. 
. 
. 
. levelsof sector, local(seclist)
`"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"ElecMach (26-28)"' `"Food (10-12)"' `"TexWood (13-18)"' `"TranspOtherManuf (29-33)"'

. 
. tempfile temp

. 
. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/estimates_sec_`title'.dta", clear

. 
. drop if sector1==sector
(0 observations deleted)

. 
. keep if type=="manuf" 
(315 observations deleted)

. 
. sum num_aff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |        162    67.87654    78.91766          1        406

. 
. replace DA=. if num_aff<3
(4 real changes made, 4 to missing)

. 
. replace DP=. if num_aff<3
(0 real changes made)

. 
. 
. 
. 
. 
. local grvar0 "LP_ppp_emp_pwt" 

. 
. local grvar1 ""

. 
. local var3 "A"

. 
. local yy "2016"

. 
. local yy_ref=`yy'

. 
. replace year=`yy_ref'
(0 real changes made)

. 
. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was int, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                               162  (_merge==3)
    -----------------------------------------

. 
. drop if _merge==2
(2,985 observations deleted)

. 
. drop _merge

. 
. rename DA D_A 

. 
. 
. 
. foreach var in D_A  {
  2. 
. gen `var'_phi=(-1)*`var'*(0.2)
  3. 
. *---------------------------------------
. 
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. 
. }
(4 missing values generated)
(4 missing values generated)

. levelsof sector, local(seclist)
`"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"ElecMach (26-28)"' `"Food (10-12)"' `"TexWood (13-18)"' `"TranspOtherManuf (29-33)"'

. 
. tempfile temp

. 
. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000w.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000w.tmp saved

. 
. local selecsec "Basic Metals (24-25)"

. 
. use `temp', clear

. 
. keep if year==`yy' & sector=="`selecsec'"
(135 observations deleted)

. local LHS1 D_`var3'_phi

. 
. local LHS2 b_D_`var3'_phi_`grvar0'

. 
. local RHS ln_`grvar0'

. 
. 
. 
. sum `LHS1' `RHS'  `LHS2'

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.2108821    .2802855  -.7914315   .4802361
ln_LP_ppp_.. |         27   -.3526483    .3908047  -1.189091   .1104476
b_D_A_phi_~t |         27   -.1417663    .3387626  -.8345065   .7133399

. 
. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. 
. local xtitle "{&Delta}y{sub:n}"

. 
. 
. 
. reg `LHS1' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =      9.86
       Model |  .577904412         1  .577904412   Prob > F        =    0.0043
    Residual |   1.4646553        25  .058586212   R-squared       =    0.2829
-------------+----------------------------------   Adj R-squared   =    0.2542
       Total |  2.04255971        26  .078559989   Root MSE        =    .24205

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .3814885    .121465     3.14   0.004     .1313267    .6316504
            _cons |  -.0763508   .0632823    -1.21   0.239    -.2066831    .0539816
-----------------------------------------------------------------------------------

. 
. mat b = e(b)

. 
. mat V = e(V)

. 
. global c1: display %-03.2fc round(b[1,1],0.01)

. 
. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. 
. 
. reg `LHS2' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     25.93
       Model |   1.5191074         1   1.5191074   Prob > F        =    0.0000
    Residual |  1.46465529        25  .058586212   R-squared       =    0.5091
-------------+----------------------------------   Adj R-squared   =    0.4895
       Total |  2.98376269        26  .114760103   Root MSE        =    .24205

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .6185114    .121465     5.09   0.000     .3683496    .8686733
            _cons |   .0763508   .0632823     1.21   0.239    -.0539816    .2066831
-----------------------------------------------------------------------------------

. 
. mat b = e(b)

. 
. mat V = e(V)

. 
. global c2: display %-03.2fc round(b[1,1],0.01)

. 
. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. 
. 
. display $c1
.38

. 
. display $se1
.12

. 
. display $c2
.62

. 
. display $se2
.12

. do "C:\Users\VANESS~1\AppData\Local\Temp\STD2d9c_000000.tmp"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: figure_A3_phi_vs_z_manufsectors.do
> Date: October 2022
> 
> Description: Reproduces Figure A3: Dev. accounting: Manufacturing sectors.
> 
> *****************************************************************************************/
. 
. *-------------------------------------------------------------------------------
. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. *cap log close
. *log using "${clogs}/figure_A3_phi_vs_z_manufsectors.log",replace
. *-------------------------------------------------------------------------------
. 
. 
. local title "naics_sales_s1_base_woparent"

. clear all

. use "${data}/estimates_sec_`title'.dta", clear

. drop if sector1==sector
(0 observations deleted)

. keep if type=="manuf" 
(315 observations deleted)

. sum num_aff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |        162    67.87654    78.91766          1        406

. replace DA=. if num_aff<3
(4 real changes made, 4 to missing)

. replace DP=. if num_aff<3
(0 real changes made)

. 
. 
. local grvar0 "LP_ppp_emp_pwt" 

. local grvar1 "" 

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was int, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                               162  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(2,985 observations deleted)

. drop _merge

. rename DA D_A 

. 
. foreach var in D_A  {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. *---------------------------------------
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. }
(4 missing values generated)
(4 missing values generated)

. 
. 
. levelsof sector, local(seclist)
`"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"ElecMach (26-28)"' `"Food (10-12)"' `"TexWood (13-18)"' `"TranspOtherManuf (29-33)"'

. tempfile temp

. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000x.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000x.tmp saved

. 
. 
. 
. 
. ***foreach selecsec of local seclist {
. ***display "`selecsec'"
. 
. 
. local selecsec "Basic Metals (24-25)"

. use `temp', clear

. keep if year==`yy' & sector=="`selecsec'"
(135 observations deleted)

. 
. local LHS1 D_`var3'_phi

. local LHS2 b_D_`var3'_phi_`grvar0'

. local RHS ln_`grvar0'

.         
. sum `LHS1' `RHS'  `LHS2'

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.2108821    .2802855  -.7914315   .4802361
ln_LP_ppp_.. |         27   -.3526483    .3908047  -1.189091   .1104476
b_D_A_phi_~t |         27   -.1417663    .3387626  -.8345065   .7133399

. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. local xtitle "{&Delta}y{sub:n}"

. 
. reg `LHS1' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =      9.86
       Model |  .577904412         1  .577904412   Prob > F        =    0.0043
    Residual |   1.4646553        25  .058586212   R-squared       =    0.2829
-------------+----------------------------------   Adj R-squared   =    0.2542
       Total |  2.04255971        26  .078559989   Root MSE        =    .24205

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .3814885    .121465     3.14   0.004     .1313267    .6316504
            _cons |  -.0763508   .0632823    -1.21   0.239    -.2066831    .0539816
-----------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c1: display %-03.2fc round(b[1,1],0.01)

. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. reg `LHS2' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     25.93
       Model |   1.5191074         1   1.5191074   Prob > F        =    0.0000
    Residual |  1.46465529        25  .058586212   R-squared       =    0.5091
-------------+----------------------------------   Adj R-squared   =    0.4895
       Total |  2.98376269        26  .114760103   Root MSE        =    .24205

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .6185114    .121465     5.09   0.000     .3683496    .8686733
            _cons |   .0763508   .0632823     1.21   0.239    -.0539816    .2066831
-----------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c2: display %-03.2fc round(b[1,1],0.01)

. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. display $c1
.38

. display $se1
.12

. display $c2
.62

. display $se2
.12

. 
. global opt1 msymbol(circle_hollow) mlabel(isocode) mlabcolor(red)  msize(medium) mlabsize(small)

. global opt2 msymbol(square_hollow) mlabel(isocode) mlabcolor(blue) msize(medium) mlabsize(small)

. two (scatter `LHS1' `RHS', sort $opt1  mcolor(red)) (lfit `LHS1' `RHS', lcolor(red)) (line `RHS' `RHS', lcolor(none))  ///
>         (scatter `LHS2' `RHS', sort $opt2  mcolor(blue)) (lfit `LHS2' `RHS', lcolor(blue)) (line `RHS' `RHS', lcolor(none)),  xscale(titlegap(*1)) ylabel(-1.5(0.5)1, format(%5.
> 1f) labsize(medlarge)) xlabel(, format(%5.1f) labsize(medlarge)) ///
>         title("", size(small)) ytitle("`ytitle'", size(medlarge)) xtitle("`xtitle'", size(medlarge)) graphregion(fcolor(white) lcolor(white)) ///
>         legend(order(2 "`firm_emb': $c1 ($se1)" 5 "`ctry_emb': $c2 ($se2)") rows(2) size(medlarge) bplace(se) ring(0) region(lwidth(none))) 

. 
.         display "`selecsec'"    
Basic Metals (24-25)

. 
end of do-file

. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/estimates_sec_`title'.dta", clear

. 
. drop if sector1==sector
(0 observations deleted)

. 
. keep if type=="manuf" 
(315 observations deleted)

. 
. 
. 
. local grvar0 "LP_ppp_emp_pwt" 

. 
. local grvar1 ""

. 
. local var3 "A"

. 
. local yy "2016"

. 
. local yy_ref=`yy'

. 
. replace year=`yy_ref'
(0 real changes made)

. 
. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was int, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                               162  (_merge==3)
    -----------------------------------------

. 
. drop if _merge==2
(2,985 observations deleted)

. 
. drop _merge

. 
. rename DA D_A 

. 
. 
. 
. foreach var in D_A  {
  2. 
. gen `var'_phi=(-1)*`var'*(0.2)
  3. 
. *---------------------------------------
. 
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. 
. }

. 
. 
. 
. 
. 
. levelsof sector, local(seclist)
`"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"ElecMach (26-28)"' `"Food (10-12)"' `"TexWood (13-18)"' `"TranspOtherManuf (29-33)"'

. 
. tempfile temp

. 
. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000x.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000x.tmp saved

. 
. 
. 
. 
. 
. 
. 
. 
. 
. ***foreach selecsec of local seclist {

. 
. ***display "`selecsec'"

. 
. 
. 
. 
. 
. local selecsec "Basic Metals (24-25)"

. 
. local selecsec "Food (10-12)"

. 
. use `temp', clear

. 
. keep if year==`yy' & sector=="`selecsec'"
(135 observations deleted)

. 
. sum num_aff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    38.77778    32.11438          1        112

. 
. replace DA=. if num_aff<3
variable DA not found
r(111);

. 
. replace DP=. if num_aff<3
(0 real changes made)

. replace D_A=. if num_aff<3
(2 real changes made, 2 to missing)

. 
. local LHS1 D_`var3'_phi

. 
. local LHS2 b_D_`var3'_phi_`grvar0'

. 
. local RHS ln_`grvar0'

. 
. 
. 
. sum `LHS1' `RHS'  `LHS2'

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.2927156    .2191985  -.7440919    .029559
ln_LP_ppp_.. |         27   -.3526483    .3908047  -1.189091   .1104476
b_D_A_phi_~t |         27   -.0599327    .3530944  -.9446985   .6301731

. 
. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. 
. local xtitle "{&Delta}y{sub:n}"

. 
. 
. 
. reg `LHS1' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =      6.14
       Model |  .246473993         1  .246473993   Prob > F        =    0.0203
    Residual |    1.002774        25   .04011096   R-squared       =    0.1973
-------------+----------------------------------   Adj R-squared   =    0.1652
       Total |  1.24924799        26     .048048   Root MSE        =    .20028

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .2491375   .1005044     2.48   0.020     .0421448    .4561301
            _cons |  -.2048577    .052362    -3.91   0.001    -.3126992   -.0970162
-----------------------------------------------------------------------------------

. 
. mat b = e(b)

. 
. mat V = e(V)

. 
. global c1: display %-03.2fc round(b[1,1],0.01)

. 
. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. 
. 
. reg `LHS2' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     55.81
       Model |  2.23879258         1  2.23879258   Prob > F        =    0.0000
    Residual |    1.002774        25   .04011096   R-squared       =    0.6907
-------------+----------------------------------   Adj R-squared   =    0.6783
       Total |  3.24156658        26  .124675638   Root MSE        =    .20028

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .7508625   .1005044     7.47   0.000     .5438699    .9578552
            _cons |   .2048577    .052362     3.91   0.001     .0970162    .3126992
-----------------------------------------------------------------------------------

. 
. mat b = e(b)

. 
. mat V = e(V)

. 
. global c2: display %-03.2fc round(b[1,1],0.01)

. 
. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. 
. 
. display $c1
.25

. 
. display $se1
.1

. 
. display $c2
.75

. 
. display $se2
.1

. ***foreach selecsec of local seclist {global typeden=1

. 
. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. . 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. 
. global lf "LF"

. 
. 
. 
. *Log

. 
. *cap log close

. 
. *log using "${clogs}/figure_A3_phi_vs_z_manufsectors.log",replace

. 
. *-------------------------------------------------------------------------------

. 
. 
. 
. 
. 
. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/estimates_sec_`title'.dta", clear

. 
. drop if sector1==sector
(0 observations deleted)

. 
. keep if type=="serv" 
(315 observations deleted)

. 
. 
. 
. local grvar0 "LP_ppp_emp_pwt" 

. 
. local grvar1 ""

. 
. local var3 "A"

. 
. local yy "2016"

. 
. local yy_ref=`yy'

. 
. replace year=`yy_ref'
(0 real changes made)

. 
. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was int, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                               162  (_merge==3)
    -----------------------------------------

. 
. drop if _merge==2
(2,985 observations deleted)

. 
. drop _merge

. 
. rename DA D_A 

. 
. 
. 
. foreach var in D_A  {
  2. 
. gen `var'_phi=(-1)*`var'*(0.2)
  3. 
. *---------------------------------------
. 
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. 
. }

. 
. 
. 
. 
. 
. levelsof sector, local(seclist)
`"Accomod_Recreat (I-R-S)"' `"Financial_Insurance (K)"' `"Information (J)"' `"Support_Services (M-N)"' `"Transportation_Storage (H)"' `"Wholesale_Retail (G)"'

. 
. tempfile temp

. 
. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000010.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000010.tmp saved

. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/estimates_sec_`title'.dta", clear

. 
. drop if sector1==sector
(0 observations deleted)

. 
. ****keep if type=="serv" 

. 
. 
. 
. local grvar0 "LP_ppp_emp_pwt" 

. 
. local grvar1 ""

. 
. local var3 "A"

. 
. local yy "2016"

. 
. local yy_ref=`yy'

. 
. replace year=`yy_ref'
(0 real changes made)

. 
. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was int, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,905
        from master                         0  (_merge==1)
        from using                      2,905  (_merge==2)

    matched                               477  (_merge==3)
    -----------------------------------------

. 
. drop if _merge==2
(2,905 observations deleted)

. 
. drop _merge

. 
. rename DA D_A 

. 
. 
. 
. foreach var in D_A  {
  2. 
. gen `var'_phi=(-1)*`var'*(0.2)
  3. 
. *---------------------------------------
. 
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. 
. }
(1 missing value generated)
(1 missing value generated)

. 
. 
. 
. 
. 
. levelsof sector, local(seclist)
`"Accomod_Recreat (I-R-S)"' `"AgrMining (A-B)"' `"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"Construction (F)"' `"Education (P)"' `"ElecMach (26-28)"' `"Electricity (D-E)"' `
> "Financial_Insurance (K)"' `"Food (10-12)"' `"Health (Q)"' `"Information (J)"' `"Public_Administration (O)"' `"Real_Estate (L)"' `"Support_Services (M-N)"' `"TexWood (13-18)"' 
> `"TranspOtherManuf (29-33)"' `"Transportation_Storage (H)"' `"Wholesale_Retail (G)"'

. 
. tempfile temp

. 
. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000011.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000011.tmp saved

. 
. local selecsec "Basic Metals (24-25)"

. 
. local selecsec "Food (10-12)"

. 
. local selecsec  "Transportation_Storage (H)"

. 
. use `temp', clear

. 
. keep if year==`yy' & sector=="`selecsec'"
(450 observations deleted)

. 
. sum num_aff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    82.33333     56.2385          3        192

. 
. *replace D_A=. if num_aff<3

. 
. 
. 
. 
. 
. local LHS1 D_`var3'_phi

. 
. local LHS2 b_D_`var3'_phi_`grvar0'

. 
. local RHS ln_`grvar0'

. 
. sum `LHS1' `RHS'  `LHS2'

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.1596197    .1230724  -.3212234    .084976
ln_LP_ppp_.. |         27   -.2120838    .2257445  -.6850934   .2709592
b_D_A_phi_~t |         27   -.0524642    .2049774  -.4018116   .4521637

. 
. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. 
. local xtitle "{&Delta}y{sub:n}"

. 
. 
. 
. reg `LHS1' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =      5.79
       Model |  .074030718         1  .074030718   Prob > F        =    0.0239
    Residual |  .319786319        25  .012791453   R-squared       =    0.1880
-------------+----------------------------------   Adj R-squared   =    0.1555
       Total |  .393817036        26  .015146809   Root MSE        =     .1131

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .2363753   .0982553     2.41   0.024     .0340147    .4387359
            _cons |  -.1094883    .030133    -3.63   0.001    -.1715483   -.0474283
-----------------------------------------------------------------------------------

. 
. mat b = e(b)

. 
. mat V = e(V)

. 
. global c1: display %-03.2fc round(b[1,1],0.01)

. 
. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. reg `LHS2' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     60.40
       Model |  .772622993         1  .772622993   Prob > F        =    0.0000
    Residual |  .319786313        25  .012791453   R-squared       =    0.7073
-------------+----------------------------------   Adj R-squared   =    0.6956
       Total |  1.09240931        26  .042015743   Root MSE        =     .1131

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .7636247   .0982553     7.77   0.000     .5612641    .9659853
            _cons |   .1094883    .030133     3.63   0.001     .0474283    .1715483
-----------------------------------------------------------------------------------

. 
. mat b = e(b)

. 
. mat V = e(V)

. 
. global c2: display %-03.2fc round(b[1,1],0.01)

. 
. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. 
. 
. display $c1
.24

. 
. display $se1
.1

. 
. display $c2
.76

. 
. display $se2
.1

. do "C:\Users\VANESS~1\AppData\Local\Temp\STD2d9c_000000.tmp"

. 
. *-------------------------------------------------------------------------------
. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. *cap log close
. *log using "${clogs}/figure_A3_phi_vs_z_manufsectors.log",replace
. *-------------------------------------------------------------------------------
. 
. 
. local title "naics_sales_s1_base_woparent"

. clear all

. use "${data}/estimates_sec_`title'.dta", clear

. drop if sector1==sector
(0 observations deleted)

. ****keep if type=="serv" 
. 
. local grvar0 "LP_ppp_emp_pwt" 

. local grvar1 "" 

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode sector using "${output}/aggregates_tfp_lp_klems.dta" 
file /aggregates_tfp_lp_klems.dta not found
r(601);

end of do-file

r(601);

. do "C:\Users\VANESS~1\AppData\Local\Temp\STD2d9c_000000.tmp"

. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. *cap log close
. *log using "${clogs}/figure_A3_phi_vs_z_manufsectors.log",replace
. *-------------------------------------------------------------------------------
. 
. 
. local title "naics_sales_s1_base_woparent"

. clear all

. use "${data}/estimates_sec_`title'.dta", clear

. drop if sector1==sector
(0 observations deleted)

. ****keep if type=="serv" 
. 
. local grvar0 "LP_ppp_emp_pwt" 

. local grvar1 "" 

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode sector using "${data}/aggregates_tfp_lp_klems.dta" 
(note: variable sector was str26, now str37 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                        12,035
        from master                         0  (_merge==1)
        from using                     12,035  (_merge==2)

    matched                               477  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(12,035 observations deleted)

. drop _merge

. rename DA D_A 

. 
. foreach var in D_A  {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. *---------------------------------------
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. }
(1 missing value generated)
(1 missing value generated)

. 
. 
. levelsof sector, local(seclist)
`"Accomod_Recreat (I-R-S)"' `"AgrMining (A-B)"' `"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"Construction (F)"' `"Education (P)"' `"ElecMach (26-28)"' `"Electricity (D-E)"' `
> "Financial_Insurance (K)"' `"Food (10-12)"' `"Health (Q)"' `"Information (J)"' `"Public_Administration (O)"' `"Real_Estate (L)"' `"Support_Services (M-N)"' `"TexWood (13-18)"' 
> `"TranspOtherManuf (29-33)"' `"Transportation_Storage (H)"' `"Wholesale_Retail (G)"'

. tempfile temp

. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000012.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000012.tmp saved

. 
. 
. 
. 
. ***foreach selecsec of local seclist {
. ***display "`selecsec'"
. 
. 
. local selecsec "Basic Metals (24-25)"

. local selecsec "Food (10-12)"

. local selecsec  "Transportation_Storage (H)"

. use `temp', clear

. keep if year==`yy' & sector=="`selecsec'"
(450 observations deleted)

. sum num_aff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    82.33333     56.2385          3        192

. replace D_A=. if num_aff<3
(0 real changes made)

. 
. 
. local LHS1 D_`var3'_phi

. local LHS2 b_D_`var3'_phi_`grvar0'

. local RHS ln_`grvar0'

.         
. sum `LHS1' `RHS'  `LHS2'

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.1596197    .1230724  -.3212234    .084976
ln_LP_ppp_.. |         27   -.0798557    .2790346  -.6839539   .5225512
b_D_A_phi_~t |         27    .0797639    .2611976    -.38562   .6818415

. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. local xtitle "{&Delta}y{sub:n}"

. 
. reg `LHS1' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =      3.74
       Model |  .051274615         1  .051274615   Prob > F        =    0.0644
    Residual |  .342542421        25  .013701697   R-squared       =    0.1302
-------------+----------------------------------   Adj R-squared   =    0.0954
       Total |  .393817036        26  .015146809   Root MSE        =    .11705

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .1591499   .0822702     1.93   0.064    -.0102887    .3285886
            _cons |  -.1469106   .0234655    -6.26   0.000    -.1952388   -.0985824
-----------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c1: display %-03.2fc round(b[1,1],0.01)

. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. reg `LHS2' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =    104.46
       Model |  1.43128626         1  1.43128626   Prob > F        =    0.0000
    Residual |  .342542419        25  .013701697   R-squared       =    0.8069
-------------+----------------------------------   Adj R-squared   =    0.7992
       Total |  1.77382868        26   .06822418   Root MSE        =    .11705

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |     .84085   .0822702    10.22   0.000     .6714114    1.010289
            _cons |   .1469106   .0234655     6.26   0.000     .0985824    .1952388
-----------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c2: display %-03.2fc round(b[1,1],0.01)

. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. display $c1
.16

. display $se1
.08

. display $c2
.84

. display $se2
.08

. 
. global opt1 msymbol(circle_hollow) mlabel(isocode) mlabcolor(red)  msize(medium) mlabsize(small)

. global opt2 msymbol(square_hollow) mlabel(isocode) mlabcolor(blue) msize(medium) mlabsize(small)

. two (scatter `LHS1' `RHS', sort $opt1  mcolor(red)) (lfit `LHS1' `RHS', lcolor(red)) (line `RHS' `RHS', lcolor(none))  ///
>         (scatter `LHS2' `RHS', sort $opt2  mcolor(blue)) (lfit `LHS2' `RHS', lcolor(blue)) (line `RHS' `RHS', lcolor(none)),  xscale(titlegap(*1)) ylabel(-1.5(0.5)1, format(%5.
> 1f) labsize(medlarge)) xlabel(, format(%5.1f) labsize(medlarge)) ///
>         title("", size(small)) ytitle("`ytitle'", size(medlarge)) xtitle("`xtitle'", size(medlarge)) graphregion(fcolor(white) lcolor(white)) ///
>         legend(order(2 "`firm_emb': $c1 ($se1)" 5 "`ctry_emb': $c2 ($se2)") rows(2) size(medlarge) bplace(se) ring(0) region(lwidth(none))) 

. 
end of do-file

. do "C:\Users\VANESS~1\AppData\Local\Temp\STD2d9c_000000.tmp"

. 
. *-------------------------------------------------------------------------------
. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. *cap log close
. *log using "${clogs}/figure_A3_phi_vs_z_manufsectors.log",replace
. *-------------------------------------------------------------------------------
. 
. 
. local title "naics_sales_s1_base_woparent"

. clear all

. use "${data}/estimates_sec_`title'.dta", clear

. drop if sector1==sector
(0 observations deleted)

. keep if type=="manuf" 
(315 observations deleted)

. 
. local grvar0 "LP_ppp_emp_pwt" 

. local grvar1 "" 

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode sector using "${data}/aggregates_tfp_lp_klems.dta" 
(note: variable sector was str26, now str37 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                        12,350
        from master                         0  (_merge==1)
        from using                     12,350  (_merge==2)

    matched                               162  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(12,350 observations deleted)

. drop _merge

. rename DA D_A 

. 
. foreach var in D_A  {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. *---------------------------------------
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. }

. 
. levelsof sector, local(seclist)
`"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"ElecMach (26-28)"' `"Food (10-12)"' `"TexWood (13-18)"' `"TranspOtherManuf (29-33)"'

. tempfile temp

. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000012.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000012.tmp saved

. 
. 
. 
. 
. ***foreach selecsec of local seclist {
. ***display "`selecsec'"
. local selecsec "Basic Metals (24-25)"

. use `temp', clear

. keep if year==`yy' & sector=="`selecsec'"
(135 observations deleted)

. sum num_aff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    56.59259    53.75962          3        167

. replace D_A=. if num_aff<3
(0 real changes made)

. 
. 
. local LHS1 D_`var3'_phi

. local LHS2 b_D_`var3'_phi_`grvar0'

. local RHS ln_`grvar0'

.         
. sum `LHS1' `RHS'  `LHS2'

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.2108821    .2802855  -.7914315   .4802361
ln_LP_ppp_.. |         27   -.1352086    .3382051  -.7179848    .388784
b_D_A_phi_~t |         27    .0756735    .2617987  -.3716775   .7175848

. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. local xtitle "{&Delta}y{sub:n}"

. 
. reg `LHS1' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     18.90
       Model |  .879473146         1  .879473146   Prob > F        =    0.0002
    Residual |  1.16308657        25  .046523463   R-squared       =    0.4306
-------------+----------------------------------   Adj R-squared   =    0.4078
       Total |  2.04255971        26  .078559989   Root MSE        =    .21569

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .5438067   .1250746     4.35   0.000     .2862106    .8014027
            _cons |  -.1373547   .0448227    -3.06   0.005    -.2296689   -.0450406
-----------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c1: display %-03.2fc round(b[1,1],0.01)

. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. reg `LHS2' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     13.30
       Model |  .618915614         1  .618915614   Prob > F        =    0.0012
    Residual |  1.16308654        25  .046523462   R-squared       =    0.3473
-------------+----------------------------------   Adj R-squared   =    0.3212
       Total |  1.78200215        26  .068538544   Root MSE        =    .21569

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .4561933   .1250746     3.65   0.001     .1985973    .7137894
            _cons |   .1373547   .0448227     3.06   0.005     .0450406    .2296689
-----------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c2: display %-03.2fc round(b[1,1],0.01)

. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. display $c1
.54

. display $se1
.13

. display $c2
.46

. display $se2
.13

. 
. global opt1 msymbol(circle_hollow) mlabel(isocode) mlabcolor(red)  msize(medium) mlabsize(small)

. global opt2 msymbol(square_hollow) mlabel(isocode) mlabcolor(blue) msize(medium) mlabsize(small)

. two (scatter `LHS1' `RHS', sort $opt1  mcolor(red)) (lfit `LHS1' `RHS', lcolor(red)) (line `RHS' `RHS', lcolor(none))  ///
>         (scatter `LHS2' `RHS', sort $opt2  mcolor(blue)) (lfit `LHS2' `RHS', lcolor(blue)) (line `RHS' `RHS', lcolor(none)),  xscale(titlegap(*1)) ylabel(-1.5(0.5)1, format(%5.
> 1f) labsize(medlarge)) xlabel(, format(%5.1f) labsize(medlarge)) ///
>         title("", size(small)) ytitle("`ytitle'", size(medlarge)) xtitle("`xtitle'", size(medlarge)) graphregion(fcolor(white) lcolor(white)) ///
>         legend(order(2 "`firm_emb': $c1 ($se1)" 5 "`ctry_emb': $c2 ($se2)") rows(2) size(medlarge) bplace(se) ring(0) region(lwidth(none))) 

. 
.         display "`selecsec'"    
Basic Metals (24-25)

. 
end of do-file

. do "C:\Users\VANESS~1\AppData\Local\Temp\STD2d9c_000000.tmp"

. 
. 
. *-------------------------------------------------------------------------------
. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. *cap log close
. *log using "${clogs}/figure_A3_phi_vs_z_manufsectors.log",replace
. *-------------------------------------------------------------------------------
. 
. 
. local title "naics_sales_s1_base_woparent"

. clear all

. use "${data}/estimates_sec_`title'.dta", clear

. drop if sector1==sector
(0 observations deleted)

. keep if type=="manuf" 
(315 observations deleted)

. 
. local grvar0 "LP_ppp_emp_pwt" 

. local grvar1 "" 

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode sector using "${data}/aggregates_tfp_lp_klems.dta" 
(note: variable sector was str26, now str37 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                        12,350
        from master                         0  (_merge==1)
        from using                     12,350  (_merge==2)

    matched                               162  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(12,350 observations deleted)

. drop _merge

. rename DA D_A 

. 
. foreach var in D_A  {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. *---------------------------------------
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. }

. 
. levelsof sector, local(seclist)
`"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"ElecMach (26-28)"' `"Food (10-12)"' `"TexWood (13-18)"' `"TranspOtherManuf (29-33)"'

. tempfile temp

. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000012.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000012.tmp saved

. 
. 
. 
. 
. ***foreach selecsec of local seclist {
. ***display "`selecsec'"
. local selecsec "Basic Metals (24-25)"

. use `temp', clear

. keep if year==`yy' & sector=="`selecsec'"
(135 observations deleted)

. sum num_aff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    56.59259    53.75962          3        167

. replace D_A=. if num_aff<3
(0 real changes made)

. 
. 
. local LHS1 D_`var3'_phi

. local LHS2 b_D_`var3'_phi_`grvar0'

. local RHS ln_`grvar0'

.         
. sum `LHS1' `RHS'  `LHS2'

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.2108821    .2802855  -.7914315   .4802361
ln_LP_ppp_.. |         27   -.1352086    .3382051  -.7179848    .388784
b_D_A_phi_~t |         27    .0756735    .2617987  -.3716775   .7175848

. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. local xtitle "{&Delta}y{sub:n}"

. local firm_emb "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}" 

. local ctry_emb "{&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"

. 
. reg `LHS1' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     18.90
       Model |  .879473146         1  .879473146   Prob > F        =    0.0002
    Residual |  1.16308657        25  .046523463   R-squared       =    0.4306
-------------+----------------------------------   Adj R-squared   =    0.4078
       Total |  2.04255971        26  .078559989   Root MSE        =    .21569

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .5438067   .1250746     4.35   0.000     .2862106    .8014027
            _cons |  -.1373547   .0448227    -3.06   0.005    -.2296689   -.0450406
-----------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c1: display %-03.2fc round(b[1,1],0.01)

. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. reg `LHS2' `RHS' 

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     13.30
       Model |  .618915614         1  .618915614   Prob > F        =    0.0012
    Residual |  1.16308654        25  .046523462   R-squared       =    0.3473
-------------+----------------------------------   Adj R-squared   =    0.3212
       Total |  1.78200215        26  .068538544   Root MSE        =    .21569

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .4561933   .1250746     3.65   0.001     .1985973    .7137894
            _cons |   .1373547   .0448227     3.06   0.005     .0450406    .2296689
-----------------------------------------------------------------------------------

. mat b = e(b)

. mat V = e(V)

. global c2: display %-03.2fc round(b[1,1],0.01)

. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)

. 
. display $c1
.54

. display $se1
.13

. display $c2
.46

. display $se2
.13

. 
. global opt1 msymbol(circle_hollow) mlabel(isocode) mlabcolor(red)  msize(medium) mlabsize(small)

. global opt2 msymbol(square_hollow) mlabel(isocode) mlabcolor(blue) msize(medium) mlabsize(small)

. two (scatter `LHS1' `RHS', sort $opt1  mcolor(red)) (lfit `LHS1' `RHS', lcolor(red)) (line `RHS' `RHS', lcolor(none))  ///
>         (scatter `LHS2' `RHS', sort $opt2  mcolor(blue)) (lfit `LHS2' `RHS', lcolor(blue)) (line `RHS' `RHS', lcolor(none)),  xscale(titlegap(*1)) ylabel(-1.5(0.5)1, format(%5.
> 1f) labsize(medlarge)) xlabel(, format(%5.1f) labsize(medlarge)) ///
>         title("", size(small)) ytitle("`ytitle'", size(medlarge)) xtitle("`xtitle'", size(medlarge)) graphregion(fcolor(white) lcolor(white)) ///
>         legend(order(2 "`firm_emb': $c1 ($se1)" 5 "`ctry_emb': $c2 ($se2)") rows(2) size(medlarge) bplace(se) ring(0) region(lwidth(none))) 

. 
end of do-file

. do "C:\Users\VANESS~1\AppData\Local\Temp\STD2d9c_000000.tmp"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: figure_A3_phi_vs_z_manufsectors.do
> Date: October 2022
> 
> Description: Reproduces Figure A3: Dev. accounting: Manufacturing sectors.
> 
> *****************************************************************************************/
. 
. *-------------------------------------------------------------------------------
. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. cap log close
